<template>
  <div style="height: 100%;overflow:hidden"
       class="main">
    <x-header :left-options="{preventGoBack:true,backText: ''}"
              @on-click-back="backhome">质量整改单</x-header>
    <div class="main-container"
         style="overflow:auto;height:93%">
      <v-touch v-on:swiperight="onSwipeRight"
               :swipe-options="{direction: 'horizontal'}">
        <!-- <div id="map"></div> -->
        <div>
          <group>
            <!-- <cell title='项目（部）'
                  v-model="pro"
                  is-link
                  link='proListR1'></cell> -->
              <select-project
                title="项目（部）"
                formType="rectify"
                module="quality"
                status="add"
                :showValue="true"
                v-model="pro"
                @selectPro="selectPro"
              ></select-project>
            <!-- <span>{{pro}}</span>  -->
            <calendar v-model="checkDateS"
                      title="检查日期开始"
                      @on-change="fillDetail"> </calendar>
            <calendar v-model="checkDateE"
                      title="检查日期截至"
                      @on-change="fillDetail"> </calendar>
            <x-input title="监理单位"
                     v-model="supervision"
                     text-align=right></x-input>
            <x-input title="施工单位"
                     v-model="construct"
                     text-align=right></x-input>
            <popup-radio title="整改单位选项"
                         :options="options4"
                         v-model="option4"></popup-radio>
            <popup-radio title="总监理工程师（总监代表）"
                         :options="options1"
                         v-model="option"></popup-radio>
            <popup-radio title="项目经理"
                         :options="options1"
                         v-model="option2"></popup-radio>
            <popup-radio title="项目总工"
                         :options="options1"
                         v-model="option3"></popup-radio>
            <group title="检查类型">
              <x-textarea placeholder="请输入检查类型概况"
                          v-model="DESCRIPTION"></x-textarea>
            </group>
            <group>
              <cell title="整改内容明细">
                <x-icon id="headeright"
                        type="ios-arrow-up"
                        size="30"
                        @click="showDetail"
                        v-if="isActive"></x-icon>
                <x-icon id="headeright"
                        type="ios-arrow-down"
                        size="30"
                        @click="showDetail"
                        v-if="!isActive"></x-icon>
              </cell>
              <pull>
                <div class="collapse-wrap"
                     v-show="isActive">
                  <slot>

                    <!-- 明细表内容 -->
                    <group v-for="(item, i) in listR"
                           :key="i">
                      <!-- <divider>——————————————————————————</divider> -->
                      <div class="sup"></div>
                      <cell title="检查类型"
                            v-model="item.CHECKTYPE"></cell>
                       <cell title="类型" v-model="item.TYPE"></cell>
                      <group title="检查图片" style="border-top: 1px solid #f5f5f5;">
                        <picture-upload :fieldToken='item.ATTACHMENTS'
                                        :pageToken='item.ATTACHMENTS'
                                        :value='item.ATTACHMENTS'
                                        :readonly='true'></picture-upload>
                      </group>
                      <cell title="描述"
                            v-model="item.DESCRIPTION"></cell>
                      <cell title="上报人"
                            v-model="item.INPUTERFULLNAME"></cell>
                    </group>
                    <!-- <divider>——————————————————————————</divider> -->
                    <div class="sup"></div>
                  </slot>
                </div>
              </pull>
            </group>
            <popup-radio title="是否停工"
                         :options="options2"
                         v-model="isStop"
                         @on-hide="toStop"></popup-radio>
            <group title="停工备注" v-show="stopContentFlag">
              <x-textarea v-model="STOPCONTENT"></x-textarea>
            </group>
            <calendar v-model="rectifyDate"
                      title="整改期限"> </calendar>
            <x-switch title="短信通知"
                      v-model="notifyMethod"
                      :value-map="['0,0,0','0,1,0']"
                      @on-change="loga"></x-switch>

            <group>
              <div class="cell_style">
                <person-tree title="检查组长"
                             v-model="person"
                             :personid="personId"
                             :defaultValue="personId"
                             @selectUser='selectPerson'></person-tree>
              </div>
            </group>

            <group>
              <div class="cell_style">
                <person-tree title="检查组员"
                             v-model="person5"
                             :personid="person5Id"
                             :defaultValue="person5Id"
                             @selectUser='selectPerson5'
                             :multiple=true></person-tree>
              </div>
            </group>

            <cell title="签发人"
                  v-model='name'></cell>
            <cell title="联系电话"
                  v-model='phone'></cell>
            <cell title="填写部门"
                  v-model='dept'></cell>
            <cell title="填写时间"
                  v-model='inputDate'></cell>
            <group v-show="flag">
              <div class="cell_style">
                <person-tree title="施工、监理确认"
                             v-model="person2"
                             :personid="person2Id"
                             @selectUser='selectPerson2'
                             :defaultValue="person2Id"
                             :multiple=true></person-tree>
              </div>
            </group>
            <group v-show="flag">
              <div class="cell_style">
                <person-tree title="整改负责人"
                             v-model="person3"
                             :personid="person3Id"
                             @selectUser='selectPerson3'
                             :defaultValue="person3Id"
                             :multiple=true></person-tree>
              </div>
            </group>
            <group>
              <div class="cell_style">
                <person-tree title="监理单位负责人"
                             v-model="person4"
                             :personid="person4Id"
                             @selectUser='selectPerson4'
                             :defaultValue="person4Id"
                             :multiple=true></person-tree>
              </div>
            </group>

            <cell title="复核人"
                  v-model="name"></cell>
            <group>
              <div class="cell_style">
               <person-tree title="项目负责人"
                             v-model="PRJMANAGERFULLNAME"
                            :personid="PRJMANAGERNAME"
                            :defaultValue="PRJMANAGERNAME"
                             @selectUser='selectPrjManagerFullName'></person-tree>
              </div>
            </group>
            <Toast :value="toastValue"
                   :is-show-mask="true"
                   text="保存成功"
                   @on-hide="saveSuccess"></Toast>
            <Toast :value="toastValueErr"
                   :is-show-mask="true"
                   :text="err"
                   @on-hide="saveErr"
                   type="cancel"
                   width="200px"></Toast>
          </group>
          <div style="text-align:center;display:flex" class="top-border">
            <button :disabled="isDisabled" class="userBack-button_save" @click="saveRectifyDraft">暂存</button>
            <button :disabled="isDisabled" class="userBack-button_submit" @click="saveRectifyInfo">提交</button>
        </div>
        </div>
      </v-touch>
    </div>
  </div>
</template>
 
<script>
import * as L from 'leaflet'
import pull from '@/views/qualityReport/pull-down.js'
import personTree from '@/components/tree/personTree'
//Vue.L = Vue.prototype.$L = L 
import { Group, Cell, XButton, Box, GroupTitle, Flexbox, FlexboxItem, Divider, Calendar, PopupPicker, Toast, XInput, InlineXSwitch, XSwitch, FormPreview, Loading, XTextarea } from 'vux'
var map = null;
var marker = null;
var flag = 0;
export default {
  components: {
    XButton,
    Box,
    GroupTitle,
    Group,
    Flexbox,
    FlexboxItem,
    Divider,
    Group,
    Cell,
    Calendar,
    PopupPicker,
    Toast,
    XInput,
    pull,
    personTree,
    InlineXSwitch,
    XSwitch,
    FormPreview,
    Loading,
    XTextarea
  },
  name: 'HelloWorld',
  data () {
    return {
      proId: this.$route.query.proId,
      pro: this.$route.query.pro,
      //prjId: this.$route.query.proId,
      name: this.$store.state.user.ADUSER_NAME,
      phone: this.$store.state.user.mobil,
      dept: this.$store.state.user.orgName,
      userId: this.$store.state.user.USER_NO,
      DESCRIPTION: "",
      pageToken: "",
      fieldToken: "",
      buttonid: "",
      inputDate: this.$store.state.user.loginTime,
      inputDateFix: "",
      // map:"",
      checkDateS: "",
      checkDateE: "",
      supervision: "",
      construct: "",
      rectifyDate: "",
      toastValue: false,
      toastValueErr: false,
      err: '',
      isActive: true,
      options1: ["在岗", "不在岗"],
      option: "在岗",
      option2: "在岗",
      option3: "在岗",
      options2: ["是", "否","部分停工"],
      isStop: "否",
      person: "",
      personId: "",
      person2: "",
      person2Id: "",
      person3: "",
      person3Id: "",
      person4: "",
      person4Id: "",
      person5: "",
      person5Id: "",
      fatherClass: [],
      checkPro: [],
      checkItems: [],
      descriptionDetail: [],
      image: [],
      listR: [],
      proNum: 0,
      fixStop: 0,
      notifyMethod: '0,0,0',
      notifyCheck:"",
      isDisabled : false,
      stopContentFlag:false,
      STOPCONTENT:"",
      PRJMANAGERFULLNAME:this.$route.query.prjManagerFullName === undefined ? "" : this.$route.query.prjManagerFullName,
      PRJMANAGERNAME:this.$route.query.prjManagerName === undefined ? "" : this.$route.query.prjManagerName,
      options4:['施工单位','监理单位'],
      option4:'施工单位',
      flag:true,//根据整改单位选项控制是否显示施工、监理确认和整改负责人
    }
  },
  methods: {
    selectPro(val){
      console.log(val);
      this.proId = val.id;
      this.pro = val.name;
      this.PRJMANAGERFULLNAME = val.prjManagerFullName;
      this.PRJMANAGERNAME = val.prjManagerName;
    },
    selectPrjManagerFullName(val){
      this.PRJMANAGERNAME = val;
    },
    selectPerson (val) {

      this.personId = val
    },
    selectPerson2 (val) {

      this.person2Id = val
    },
    selectPerson3 (val) {

      this.person3Id = val
    },
    selectPerson4 (val) {

      this.person4Id = val
    },
    selectPerson5 (val) {

      this.person5Id = val
    },
    toStop () {
      if (this.isStop == '是'){
        this.fixStop = 1
        this.stopContentFlag = false
      }else if(this.isStop == "否"){
        this.fixStop = 0
        this.stopContentFlag = false
      }else{
        this.fixStop = 3
        this.stopContentFlag = true
      }
    },
    loga (value) {
    },
    showDetail () {
      this.isActive = !this.isActive;
    },
    onSwipeRight () {
      this.$router.push({ path: '/qualityReport', query: { proId: this.proId, proDept: this.proDept, pro: this.pro, site: this.centerPosition } })
    },
    fillDetail () {


      var params = '{"_method":"PMQUALITY_RECTIFY.getDetails","minDate":"' + this.checkDateS + '","maxDate":"' + this.checkDateE + '","sysPrjId":"' + this.proId + '","rectifyUnit":"' + this.option4 + '"}';
      this.$ajax({
        method: 'post',
        url: this.COMMON_URL + '?_objName=PMQUALITY_RECTIFY&_viewId=PMQUALITY_RECTIFY',
        data: {
          FixJSON: params
        }
      }).then((res) => {
        console.log("明细表",res);
        this.listR = res.data.returnValue;
        this.proNum = this.listR.length;
      })
    },

    backhome () {
      this.$router.push({ path: '/qualityReport', query: { flag: 1 } })
      this.$vux.loading.hide();
    },
    setRowData (DataTarget, Value, OriginalValue, PK, DataType) {
      var map = {};
      map["DataTarget"] = DataTarget;
      map["Value"] = Value;
      map["OriginalValue"] = OriginalValue;
      map["PK"] = PK;
      map["DataType"] = DataType;
      return map;
    },
    setChildData (rowData) {
      var map = {};
      map["rowData"] = rowData;
      map["children"] = [];
      return map;
    },
    saveRectifyInfo () {
      this.isDisabled = true
      if(this.notifyMethod == '0.1.0'){
        this.notifyCheck = "SMS"
      }
      this.err = '';
      if (!this.pro) {
        this.err += "【项目（部）】不能为空<br/>";
      }
      if (this.checkDateS == '') {
        this.err += "【检查日期开始】不能为空<br/>";

      }
      if (this.checkDateE == '') {
        this.err += "【检查日期截至】不能为空<br/>";

      }
      if (this.supervision == '') {
        this.err += "【监理单位】不能为空<br/>";
      }
      if (this.construct == '') {
        this.err += "【施工单位】不能为空<br/>";
      }
      if (this.DESCRIPTION == '') {
        this.err += "【整改内容】不能为空<br/>";
      }
      if (this.rectifyDate == '') {
        this.err += "【整改期限】不能为空<br/>";
      }
      if (this.person == '') {
        this.err += "【检查组长】不能为空<br/>"
      }
      if (this.person5 == '') {
        this.err += "【检查组员】不能为空<br/>"
      }
      if(this.flag){
        if (this.person2 == '') {
          this.err += "【施工、监理确认】不能为空<br/>"
        }
        if (this.person3 == '') {
          this.err += "【整改负责人】不能为空<br/>"
        }
      }
      if (this.person4 == '') {
        this.err += "【监理单位审核】不能为空<br/>"
      }
      if (this.PRJMANAGERFULLNAME == '') {
        this.err += "【项目负责人】不能为空<br/>"
      }
      
      if (this.err != "") {
        this.toastValueErr = true;
        this.isDisabled = false;
        return false;
      }

      var guid = this.guid();
        var title = "质量整改通知单提醒";
        var content = "你管理的" + this.pro + "项目有一个新的质量整改通知单。请进入【质量整改通知单】查看详细信息。";
        var messageto = this.PRJMANAGERNAME;
        var url = process.env.BASE_URL + "qhszpm/forms/Quality/PMQUALITY_RECTIFY/PMQUALITY_RECTIFY_add.html?isBreak=false&objName=PMQUALITY_RECTIFY&_useType=view&_pk=GUID&_t=295548&_winid=w274&_pkValue=" + guid;

        var sendParams = {
          "_method":"SYS_NOTICE.sendNotice",
          "_param":{
            "messageto":messageto,
            "messagetilte":title,
            "messagecontent":content,
            "url":url,
            "messagesenttime":new Date(),
            "messageattachment":""
            } 
        }

        let sendJson = {
          FixJSON: JSON.stringify(sendParams),
        }
        this.$ajax({
          url : this.COMMON_URL,
          method : "post",
          // data: this.signMD5(sendJson)
          data:sendJson
        }).then(res => {
         }).catch((err) => {
           console.log(err);
        });

      var rowData = [this.proNum];
      var childData = [];
      var i = 0;
      for (i = 0; i < this.proNum; i++) {
        rowData[i] = new Array();
        rowData[i][0] = this.setRowData("GUID", "", null, true, "String");
        rowData[i][1] = this.setRowData("SYSPRJID", this.listR[i].SYSPRJID, null, false, "String");
        rowData[i][2] = this.setRowData("PRJNO", '', null, false, "String");
        rowData[i][3] = this.setRowData("PRJNAME", this.listR[i].PRJNAME, null, false, "String");
        rowData[i][4] = this.setRowData("PROJECTID", this.listR[i].PROJECTID, null, false, "String");
        rowData[i][5] = this.setRowData("PROJECTNAME", this.listR[i].PROJECTNAME, null, false, "String");
        rowData[i][6] = this.setRowData("DESCRIPTION", this.listR[i].DESCRIPTION, null, false, "String");
        rowData[i][7] = this.setRowData("CHECKSTATE", "未整改", null, false, "String");
        rowData[i][8] = this.setRowData("IMAGEBEFORECHECK", this.listR[i].ATTACHMENTS, null, false, "Store.ecidiDoc");
        rowData[i][9] = this.setRowData("EXPLAIN", "", null, false, "String");
        rowData[i][10] = this.setRowData("IMAGEAFTERCHECK", "", null, false, "Store.ecidiDoc");
        rowData[i][11] = this.setRowData("REPORTERNAME", this.listR[i].INPUTERNAME, null, false, "String");
        rowData[i][12] = this.setRowData("REPORTERFULLNAME", this.listR[i].INPUTERFULLNAME, null, false, "String");
        rowData[i][13] = this.setRowData("PREGUID", this.listR[i].GUID, null, false, "String");
        rowData[i][14] = this.setRowData("CHECKDATE", this.listR[i].CHECKYEARANDMONTH, null, false, "String");
        rowData[i][15] = this.setRowData("CHECKTYPE", this.listR[i].CHECKTYPE, null, false, "String");
        childData[i] = this.setChildData(rowData[i]);
      }
      var params = {
        "_method": "formService.saveFormData",
        "requestEventData": {
          "eventType": "formSubmitEvent",
          "formType": 1,
          "bizObjId": "PMQUALITY_RECTIFY",
          "formId": "PMQUALITY_RECTIFY_add",
          "buttonId": "HandleCommand_1"        },
        "flowParam": {
          "defKey": "PMQUALITY_RECTIFY",
          "nodeId": "UserTask_1",
          "userCommandType": "startandsubmit",
          "userCommandId": "HandleCommand_1",
          "isAdmin": "false",
          "taskComment": "", "extParam": {}        },
        "_OBJ_NAME_": "PMQUALITY_RECTIFY",
        "_FORM_ID_": "PMQUALITY_RECTIFY_add",
        "useType": "add",
        "pageToken": this.guid(),
        "formData": {
          "objName": "PMQUALITY_RECTIFY",
          "pks": ["GUID"],
          "data": [{            "rowData": [
              { "DataTarget": "GUID", "Value": guid, "OriginalValue": null, "PK": true, "DataType": "String" },
              { "DataTarget": "STATE", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PRJNAME", "Value": this.pro, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "SYSPRJID", "Value": this.proId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "MINDATE", "Value": this.checkDateS, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "MAXDATE", "Value": this.checkDateE, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "SUPERVISIONUNIT", "Value": this.supervision, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "CONSTRUCTIONNAME", "Value": this.construct, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "WORKSTAFF1", "Value": this.option, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "WORKSTAFF2", "Value": this.option2, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "WORKSTAFF3", "Value": this.option3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCONTENT", "Value": this.DESCRIPTION, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCOMNUM", "Value": 0, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "RECTIFYNUM", "Value": this.proNum, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "CLOSERATE", "Value": "0%", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "FLAG", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "ISSTOP", "Value": this.fixStop, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "STOPCONTENT", "Value": this.STOPCONTENT, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYDATE", "Value": this.rectifyDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "NOTIFYCHECK", "Value": this.notifyCheck, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "NOTIFYMETHOD", "Value": this.notifyMethod, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSCHIEFRECHIFFFULLNAME", "Value": this.person, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONCHIEFNAME", "Value": this.personId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONMEMBERFULLNAME", "Value": this.person5, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONMEMBERNAME", "Value": this.person5Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERFULLNAME", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERNAME", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PHONENUM", "Value": this.phone, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERDEPTNAME", "Value": this.dept, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTDATE", "Value": this.inputDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "AUDITUSERFULLNAME1", "Value": this.person3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME1", "Value": this.person3Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME2", "Value": this.person4, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME2", "Value": this.person4Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME3", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME3", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYUNIT", "Value": this.option4, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME4", "Value": this.person2, "OriginalValue": null, "PK": false, "DataType": "String" },
                    { "DataTarget": "PRJMANAGERFULLNAME", "Value": this.PRJMANAGERFULLNAME, "OriginalValue": null, "PK": false, "DataType": "String" },
               { "DataTarget": "PRJMANAGERNAME", "Value": this.PRJMANAGERNAME, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME4", "Value": this.person2Id, "OriginalValue": null, "PK": false, "DataType": "String" }],
            "children": [{ "objName": "PMQUALITY_RECTIFY_DETAIL", "pks": ["GUID"], "data": childData }]          }]        },
        "_ATTACHMENT_DELETE_IDS_": "",
        "formInfo": {}
      }
      let json = {
        FixJSON: JSON.stringify(params),
      }
      this.$ajax({
        url: this.COMMON_URL, //+ '?_objName=PMQUALITY_RECTIFY&_useType=add&_defKey=PMQUALITY_RECTIFY&_pk=GUID&_pkValue=undefined',
        method: 'post',
        // data: this.signMD5(json)
        data:json
      }).then(res => {
        this.$vux.loading.show({
            text:"Loading"
          })
        var guid = []
        for (i = 0; i < this.proNum; i++) {
          guid.push("'" + this.listR[i].GUID + "'")
        }
        guid = guid.join(",")
        this.changState(guid);
        this.toastValue = true;
      }).catch((err) => {
        this.isDisabled = false;
        alert(err);
      });
    },
    changState (guid) {
      let params = {
        FixJSON: { "_method": "PMQUALITY_RECTIFY.changeFlag", "guid": guid }
      }
      this.$ajax({
        url: this.COMMON_URL + "?_objName=PMQUALITY_RECTIFY&_useType=add&_defKey=PMQUALITY_RECTIFY&_pk=GUID&_pkValue=undefined",
        method: 'post',
        params: params
      }).then(res => {
        console.log("success")
      })
    },
    saveRectifyDraft () {
      this.isDisabled = true;
      if(this.notifyMethod == '0.1.0'){
        this.notifyCheck = "SMS"
      }
      var rowData = [this.proNum];
      var childData = [];
      var i = 0;
      for (i = 0; i < this.proNum; i++) {
        rowData[i] = new Array();
        rowData[i][0] = this.setRowData("GUID", "", null, true, "String");
        rowData[i][1] = this.setRowData("SYSPRJID", this.listR[i].SYSPRJID, null, false, "String");
        rowData[i][2] = this.setRowData("PRJNO", '', null, false, "String");
        rowData[i][3] = this.setRowData("PRJNAME", this.listR[i].PRJNAME, null, false, "String");
        rowData[i][4] = this.setRowData("PROJECTID", this.listR[i].PROJECTID, null, false, "String");
        rowData[i][5] = this.setRowData("PROJECTNAME", this.listR[i].PROJECTNAME, null, false, "String");
        rowData[i][6] = this.setRowData("DESCRIPTION", this.listR[i].DESCRIPTION, null, false, "String");
        rowData[i][7] = this.setRowData("CHECKSTATE", "未整改", null, false, "String");
        rowData[i][8] = this.setRowData("IMAGEBEFORECHECK", this.listR[i].ATTACHMENTS, null, false, "Store.ecidiDoc");
        rowData[i][9] = this.setRowData("EXPLAIN", "", null, false, "String");
        rowData[i][10] = this.setRowData("IMAGEAFTERCHECK", "", null, false, "Store.ecidiDoc");
        rowData[i][11] = this.setRowData("REPORTERNAME", this.listR[i].INPUTERNAME, null, false, "String");
        rowData[i][12] = this.setRowData("REPORTERFULLNAME", this.listR[i].INPUTERFULLNAME, null, false, "String");
        rowData[i][13] = this.setRowData("PREGUID", this.listR[i].GUID, null, false, "String");
        rowData[i][14] = this.setRowData("CHECKDATE", this.listR[i].CHECKYEARANDMONTH, null, false, "String");
        rowData[i][15] = this.setRowData("CHECKTYPE", this.listR[i].CHECKTYPE, null, false, "String");
        childData[i] = this.setChildData(rowData[i]);
      }
      var params = {
        "_method": "formService.saveFormData",
        "requestEventData": {
          "eventType": "formSubmitEvent",
          "formType": 1,
          "bizObjId": "PMQUALITY_RECTIFY",
          "formId": "PMQUALITY_RECTIFY_add",
          "buttonId": "HandleCommand_3"        },
        "flowParam": {
          "defKey": "PMQUALITY_RECTIFY",
          "nodeId": "UserTask_1",
          "userCommandType": "saveTaskDraft",
          "userCommandId": "HandleCommand_3",
          "isAdmin": "false",
          "taskComment": "", "extParam": {}        },
        "_OBJ_NAME_": "PMQUALITY_RECTIFY",
        "_FORM_ID_": "PMQUALITY_RECTIFY_add",
        "useType": "add",
        "pageToken": this.guid(),
        "formData": {
          "objName": "PMQUALITY_RECTIFY",
          "pks": ["GUID"],
          "data": [{            "rowData": [
              { "DataTarget": "GUID", "Value": "", "OriginalValue": null, "PK": true, "DataType": "String" },
              { "DataTarget": "STATE", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PRJNAME", "Value": this.pro, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "SYSPRJID", "Value": this.proId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "MINDATE", "Value": this.checkDateS, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "MAXDATE", "Value": this.checkDateE, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "SUPERVISIONUNIT", "Value": this.supervision, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "CONSTRUCTIONNAME", "Value": this.construct, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "WORKSTAFF1", "Value": this.option, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "WORKSTAFF2", "Value": this.option2, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "WORKSTAFF3", "Value": this.option3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCONTENT", "Value": this.DESCRIPTION, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCOMNUM", "Value": 0, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "RECTIFYNUM", "Value": this.proNum, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "CLOSERATE", "Value": "0%", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "FLAG", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "ISSTOP", "Value": this.fixStop, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "STOPCONTENT", "Value": this.STOPCONTENT, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYDATE", "Value": this.rectifyDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "NOTIFYCHECK", "Value": this.notifyCheck, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "NOTIFYMETHOD", "Value": this.notifyMethod, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSCHIEFRECHIFFFULLNAME", "Value": this.person, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONMEMBERFULLNAME", "Value": this.person5, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERFULLNAME", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERNAME", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PHONENUM", "Value": this.phone, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERDEPTNAME", "Value": this.dept, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTDATE", "Value": this.inputDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "AUDITUSERFULLNAME1", "Value": this.person3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME1", "Value": this.person3Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME2", "Value": this.person4, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME2", "Value": this.person4Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME3", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME3", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYUNIT", "Value": this.option4, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME4", "Value": this.person2, "OriginalValue": null, "PK": false, "DataType": "String" },
                    { "DataTarget": "PRJMANAGERFULLNAME", "Value": this.PRJMANAGERFULLNAME, "OriginalValue": null, "PK": false, "DataType": "String" },
               { "DataTarget": "PRJMANAGERNAME", "Value": this.PRJMANAGERNAME, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME4", "Value": this.person2Id, "OriginalValue": null, "PK": false, "DataType": "String" }],
            "children": [{ "objName": "PMQUALITY_RECTIFY_DETAIL", "pks": ["GUID"], "data": childData }]          }]        },
        "_ATTACHMENT_DELETE_IDS_": "",
        "formInfo": {}
      }
      let json = {
        FixJSON: JSON.stringify(params),
      }
      this.err = '';
      if (!this.pro) {
        this.err += "【项目（部）】不能为空<br/>";
      }
      if (this.err != "") {
        this.isDisabled = false;
        this.toastValueErr = true;
        return false;
      }

      this.$ajax({
        url: this.COMMON_URL, //+ '?_objName=PMQUALITY_RECTIFY&_useType=add&_defKey=PMQUALITY_RECTIFY&_pk=GUID&_pkValue=undefined',
        method: 'post',
        // data: this.signMD5(json)
        data:json
      }).then(res => {
        this.$vux.loading.show({
            text:"Loading"
          })
        this.toastValue = true;
      }).catch((err) => {
        this.isDisabled = false;
        alert(err);
      });
    },
    saveSuccess () {
      this.backhome();
    },
    saveErr () {
      this.toastValueErr = false;
    },
    /**
     * 设置默认的检查日期，格式为xxxx-xx-xx
     */
    setDefautlDate () {
      let now = new Date();
      let month = now.getMonth() + 1;
      let day = now.getDate();
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = "0" + day
      }
      this.inputDate = now.getFullYear() + "-" + month + "-" + day;

    }
  },
  mounted () {
    this.setDefautlDate();
    if (this.proId) {
      var parameter = {
        _method: "component.getListData",
        _param: {
          bizObj: "PMBASE_PRJMANAG",
          service: "selectPMStaffMore",
          fields: "*",
          filter: "1=1 AND PROJECTID='" + this.proId + "'",
          currentPageIndex: 1,
          pageSize: 50,
          orderList: [
            {
              field: "ISPRJMANAG",
              order: "desc"
            }, {
              field: "INPUTDATE", "order": "desc"
            }], QueryFormData: ""        }
      }
      this.$ajax({
        method: 'post',
        url: this.COMMON_URL,
        data: { FixJSON: JSON.stringify(parameter) }
      }).then(res => {
        var data = res.data.datas
        this.supervision = data[0].QUALITYDEPTNAME2
        this.construct = data[0].QUALITYDEPTNAME
        this.person3 = data[0].QUALITYUSERFULLNAME
        this.person3Id = data[0].QUALITYUSERNAME
        this.person4 = data[0].QUALITYUSERFULLNAME2
        this.person4Id = data[0].QUALITYUSERNAME2
        if (this.person3 && this.person4) {
          this.person2 = this.person3 + "," + this.person4
          this.person2Id = this.person3Id + ',' + this.person4Id
        } else if (this.person3 && !this.person4) {
          this.person2 = this.person3
          this.person2Id = this.person3Id
        } else if (!this.person3 && this.person4) {
          this.person2 = this.person4
          this.person2Id = this.person4Id
        } else {
          this.person2 = ''
          this.person2Id = ''
        }
      })
    }

  },
  watch: {
    option4:{
      handler(newVal){
        this.fillDetail();
        if(newVal == '施工单位'){
          this.flag = true
        }else{
          this.flag = false
        }
      }
    },
    // person: {
    //   handler (newval) {
    //     this.personId = localStorage.handleName;
    //   }
    // },
    // person2: {
    //   handler (newval) {
    //     this.person2Id = localStorage.handleName;
    //   }
    // },
    // person3: {
    //   handler (newval) {
    //     this.person3Id = localStorage.handleName;
    //   }
    // },
    // person4: {
    //   handler (newval) {
    //     this.person4Id = localStorage.handleName;
    //   }
    // },
    // person5: {
    //   handler (newval) {
    //     this.person5Id = localStorage.handleName;
    //   }
    // },
    isStop: {
      handler (newval, oldval) {
        if (newval == '是')
          this.fixStop = 1
        else
          this.fixStop = 0

      }
    },
    proId: {
      handler () {
        var parameter = {
          _method: "component.getListData",
          _param: {
            bizObj: "PMBASE_PRJMANAG",
            service: "selectPMStaffMore",
            fields: "*",
            filter: "1=1 AND PROJECTID='" + this.proId + "'",
            currentPageIndex: 1,
            pageSize: 50,
            orderList: [
              {
                field: "ISPRJMANAG",
                order: "desc"
              }, {
                field: "INPUTDATE", "order": "desc"
              }], QueryFormData: ""          }
        }
        this.$ajax({
          method: 'post',
          url: this.COMMON_URL,
          data: { FixJSON: JSON.stringify(parameter) }
        }).then(res => {
          var data = res.data.datas
          this.supervision = data[0].QUALITYDEPTNAME2
          this.construct = data[0].QUALITYDEPTNAME
          this.person3 = data[0].QUALITYUSERFULLNAME
          this.person3Id = data[0].QUALITYUSERNAME
          this.person4 = data[0].QUALITYUSERFULLNAME2
          this.person4Id = data[0].QUALITYUSERNAME2
        })
      }
    }
  }
}
</script>
 

<style scoped>
/* .transition-view /deep/ .vux-header .vux-header-left .left-arrow:before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.8);
  border-width: 1px 0 0 1px;
  -webkit-transform: rotate(315deg);
  transform: rotate(315deg);
  top: 8px;
  left: 7px;
}
.transition-view /deep/ .vux-header .vux-header-title {
  line-height: 40px;
  text-align: center;
  font-size: 18px;
  font-weight: 400;
  color: #333;
} */

#map {
  width: 100%;
  height: 25%;
}
.content {
  width: 100%;
  height: 75%;
}
.vux-x-icon {
  fill: #d9d9d9;
}
.cell-x-icon {
  display: block;
  fill: green;
}
.transition-view /deep/ .weui-cells__title {
  color: #333;
}
.cell_style{
  min-height: 38px;
}
.userBack-button_save{
      width: 40%;
      height: 40px;
      background-color: #ffffff;
      border-radius: 2pt;
      border: 1pt solid #4D86FF;
      margin-top: 20pt;
      color: #4D86FF;
      font-size: 13px;
      /* margin-left: 15px; */
        margin-right: auto;
      margin-left: auto;
      margin-bottom: 20pt;
  }
  .userBack-button_submit{
      width: 40%;
      height: 40px;
      background-color: #4D86FF;
      border-radius: 2pt;
      border: 1pt solid #4D86FF;
      margin-top: 20pt;
      color: #FFFFFF;
      font-size: 13px;
      /* margin-left: auto;
      margin-right: 5%; */
        margin-right: auto;
      margin-left: auto;
      margin-bottom: 20pt;
  }
  .top-border{
  border-top: 1px solid #f5f5f5
}
  .sup{
  width: 100%;
  height: 10px;
  border-radius: 0;
  background-color: #F5F5F5;
}
</style>